package com.weishaoying.config;

import com.meituan.service.mobile.mtthrift.proxy.ThriftServerPublisher;
import com.weishaoying.api.service.UserThriftService;
import com.weishaoying.serivce.UserServiceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author WeiShaoying
 * @date 2018/9/27
 */
@Configuration
public class JavaConfig {

    @Bean(value = "userThriftSerivce")
    public UserThriftService userThriftSerivce(){
        return new UserServiceImpl();
    }


    @Bean(name = "serverPublisher", initMethod = "publish", destroyMethod = "destroy")
    public ThriftServerPublisher getThriftServerPublisher() {
        ThriftServerPublisher serverPublisher = new ThriftServerPublisher();
        serverPublisher.setServiceInterface(UserThriftService.class);
        serverPublisher.setServiceImpl(userThriftSerivce());
        // [MUST] 服务提供者 appkey
        serverPublisher.setAppKey("com.sankuai.octo.testMTthrift");
        // [MUST] 服务提供者监听端口
        serverPublisher.setPort(9461);
        return serverPublisher;
    }

}
